﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<TireBias.Models.BIASPLANModel.BIASPLAN_DS>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>

<asp:Content ID="indexContent" ContentPlaceHolderID="FeaturedContent" runat="server">
    <%-- <section class="featured">
        <div class="content-wrapper">
            <hgroup class="title">
                <h1>BIAS NO.</h1>
                <h1><%: ViewBag.Message %></h1>
            </hgroup>           
        </div>
    </section>--%>

   
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div style="margin:auto; text-align:center; width:1200px">
    <div class="cap shadow txt13bold">
         BIAS NO :
      </div>
      <div id="code" class="desc txt13bold" style="width: 200px;">
      <input type="text" id="txtBias" value="<%=  ViewBag.Biasno  %>"  />
      </div>
      
          <div class="cap shadow txt13bold">
         PLAN DATE :
      </div>
      <div id="Txtpladt" class="desc txt13bold" style="width: 200px;">
          <input type="text" id="dFrom" value="<%=  ViewBag.dtPlan  %>"  />
         
      </div>
      
      <button  id="search"></button>
       
         <div style="clear:left" />
<%if (WinNemoLib.StrUtil.IsNotEmpty(User.Identity.Name.ToString()))
  { %>
   <ul id="menu1" class="menu1" style="vertical-align:bottom;">  
      <li class="aa" id="unlock"><a href="#">UNLock</a></li>
      <li class="aa" id="lock"><a href="#">All Lock</a></li>      
      <li id="edit" style="padding-left:78%"><a href="#">Edit</a></li>       
   </ul>
   <%} %>
 
    <table width="100%" class=" shadow "  id="dataTbl">
     <thead>
         <tr class="head"  id="trRow">
            <td class="cell "  style="width: 50px;">
               STATUS               
            </td>
            <td class="cell" style="width: 100px;">
               SEQ
            </td>
            <td class="cell" style="width: 150px;">
               TOPPED CORD
            </td>
            <td class="cell" style="width: 150px;">
               SIZE
            </td>
            <td class="cell" style="width: 50px;">
               P1
            </td>  
            <td class="cell" style="width: 50px;">
               P2
            </td>  
               <td class="cell" style="width: 50px;">
               P3
            </td>  
               <td class="cell" style="width: 50px;">
               P4
            </td>  
            <td class="cell" style="width: 120px;">
               FORMING
            </td>
             <td class="cell" style="width: 120px;">
               TEXT
            </td>
         </tr>
          
      </thead>     

       <tbody>
         <%
            int i = 0;
            
            foreach (var item in Model)
            {
               i = i + 1;
               string trrow = "rowa";
               if (i % 2 == 0) trrow = "rowb";
               string seq = item._Plandt +'-'+item._Itemno;
              
            
         %>
         <tr class='<%= trrow %>'  style="line-height:25px;">
          
            <td  style="width: 50px; text-align:center;">
               <%: Html.DisplayFor(modelItem => item._Plants) %>
            </td>
            <td style="width: 120px; text-align:center;">
               <%= seq %>
            </td>
            <td style="width: 250px; text-align:center;">
               <%: Html.DisplayFor(modelItem => item._Topcrdcd) %>
            </td>
            <td style="width: 150px;">
               <%: Html.DisplayFor(modelItem => item._Size) %>
            </td>
            <td style="width: 50px; text-align:center;">
               <%: Html.DisplayFor(modelItem => item._P1) %>
            </td>                       
            <td style="width: 50px; text-align:center;">
               <%: Html.DisplayFor(modelItem => item._P2) %>
            </td>                       
            <td style="width: 50px; text-align:center;">
               <%: Html.DisplayFor(modelItem => item._P3) %>
            </td>                       
            <td style="width: 50px; text-align:center;">
               <%: Html.DisplayFor(modelItem => item._P4) %>
            </td>                       
            <td style="width: 120px; text-align:center;">
               <%: Html.DisplayFor(modelItem => item._Forming) %>
            </td>                       
            <td style="width: 120px; text-align:center;">
               <%: Html.DisplayFor(modelItem => item._Text) %>
            </td>                       
           
           
         </tr>
         <% } %>
      </tbody>
      
   </table>
</div>
 <hr />
   <div style="clear:both; margin-top:10px;  text-align:center; width:1200px">
   <table class="shadow" id="UseTbl" style="text-align:left; margin:0px 0px 0px 0px;text-align:left; ">
  
   <thead>
         <tr class="cell" style="background-color:#ccc; color:#000; font-weight:bold;text-align:center;"><td colspan="9">USED PLAN</td></tr>
         <tr class="head"  id="trUse" style="background-color:#008080; color:White;">
            <td class="cell" style="width: 120px;">
               SEQ
            </td>
    
           <td class="cell" style="width: 150px;">
               TOPPED CORD
            </td>
            <td class="cell" style="width: 150px;">
               SIZE
            </td>
            <td class="cell" style="width: 50px;">
               P1
            </td>  
            <td class="cell" style="width: 50px;">
               P2
            </td>  
               <td class="cell" style="width: 50px;">
               P3
            </td>  
               <td class="cell" style="width: 50px;">
               P4
            </td>  
            <td class="cell" style="width: 120px;">
               FORMING
            </td>
             <td class="cell" style="width: 500px;">
               TEXT
            </td>
         </tr>         
   </thead>
   <tbody></tbody>
   </table>
   </div>

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="TableContent" runat="server">

</asp:Content>

<asp:Content ID="idJQuery" ContentPlaceHolderID="ScriptsSection" runat="server">
      <style type="text/css">
      .chk:hover
      {
         cursor: pointer;
       
      }
      .actived
      {
        color:#ff0000;      /*red*/               
      }      
    
      .txt
      {
          background-color:#f8f8e8 !important;
          border-right: #000 1px solid  !important;
      }
      .hide
      { display:none;
         }
    .skip
    {
        color:Red !important;
    }
      .samp
    {
        color:#FF6D00 !important;
    }
    .nfin
    {
         color:Blue !important;
    }
   </style>
   <% if (false) { %>
   <script src="../../Scripts/jquery-1.7.1.js" type="text/javascript"></script>
   <% } %>

     <script type="text/javascript">
         $(function () {

             var dt = $("#dFrom").val();
             var no = $("#txtBias").val();
             $("#dFrom,#txtBias").change(function () {
                 dt = $("#dFrom").val();
                 no = $("#txtBias").val();
             });
             $("#search").button({
                 icons: { primary: 'ui-icon-circle-zoomout' }, text: false
             }).click(function () {

                 var url = '<%=Url.Action("Index") %>' + '?dtPlan=' + dt;
                 url = url + '&bias=' + no;
                 window.location = url;
             }); //click

             $('#dFrom').dateEntry({ useMouseWheel: false, dateFormat: 'dmy/' })
             $("#txtBias").setMask("999");

             //Click Select Row //   
             <% if (WinNemoLib.StrUtil.IsNotEmpty(User.Identity.Name.ToString())) { %>
             $("tr.rowa, tr.rowb ").click(function () {
                 $("tr.rowa, tr.rowb").removeClass("actived");
                 var $tr = $(this);

                 $tr.addClass("actived");
                 $tr = $tr.closest('tr').next('tr');
                 while ($tr.length > 0) {
                     $tr.addClass("actived");
                     $tr = $tr.closest('tr').next('tr');
                 }

             });
             <% } %>

             //Click UNLock
             $("#unlock").click(function () {
                 var getUsersUrl = '<%= Url.Action("Index") %>' + '?dtPlan=' + dt + '&bias=' + no;
                 if ($("tr.actived:first").length <= 0) {
                     alert("กรุณาเลือกข้อมูล");
                     return false;
                 }
                 {
                     WAITINGDLG_show(imgWait);
                     sel = ($("tr.actived:first").find("td:eq(1)").text());
                     $.post('<%=Url.Action("unLock") %>' + '?sel=' + sel + '&bias=' + $("#txtBias").val(), function (data) {
                         alert(data.message);
                         if (data.success != "0") {
                             window.location = getUsersUrl;
                         }
                         WAITINGDLG_hide();
                     });
                 }
             });
             //Click LockAll
             $("#lock").click(function () {
                 WAITINGDLG_show(imgWait);
                 setTimeout(function () {
                     var getUsersUrl = '<%= Url.Action("Index") %>' + '?dtPlan=' + dt + '&bias=' + no;

                     $.post('<%=Url.Action("LockAll") %>' + '?dtPlan=' + dt + '&bias=' + no, function (data) {
                         alert(data.message);
                         if (data.success != "0") {
                             window.location = getUsersUrl;
                         }
                         WAITINGDLG_hide();
                     });
                 }, 2000)

             });

             //click edit
             $("#edit").click(function () {
                 var getUsersUrl = '<%= Url.Action("unLockTopping") %>' + '?dtPlan=' + dt + '&bias=' + no;
                 window.location = getUsersUrl;
             });

             $.post('<%=Url.Action("Get_USE_ACTIVE") %>' + '?dtPlan=' + dt + '&bias=' + no, function (data) {

                 WAITINGDLG_show(imgWait);
                 $("#UseTbl tbody").empty();

                 for (i = 0; i < data.length; i++) {
                     var seq = data[i]._Plandt + '-' + data[i]._Itemno;
                     var row = "rowa";
                     if (i % 2 == 0) {
                         row = "rowa";
                     }
                     var $tr = $("#trUse").clone().addClass(row).removeAttr("style");
                     $("td:eq(0)", $tr).text(seq).addClass("text-center");
                     $("td:eq(1)", $tr).text(data[i]._Topcrdcd).addClass("text-center");
                     $("td:eq(2)", $tr).text(data[i]._Size).addClass("text-center");
                     $("td:eq(3)", $tr).text(data[i]._P1).addClass("text-center");
                     $("td:eq(4)", $tr).text(data[i]._P2).addClass("text-center");
                     $("td:eq(5)", $tr).text(data[i]._P3).addClass("text-center");
                     $("td:eq(6)", $tr).text(data[i]._P4).addClass("text-center");
                     $("td:eq(7)", $tr).text(data[i]._Forming).addClass("text-center");
                     $("td:eq(8)", $tr).text(data[i]._Text).addClass("text-center");

                     if (data[i]._Skpflag != "") {
                         $tr.addClass("skip");
                     }
                     if (data[i]._nfinemp != "") {
                         $tr.addClass("nfin");
                     }
                     if (data[i]._Smpemp != "") {                   
                         $tr.addClass("samp");
                     }

                     $tr.appendTo($("#UseTbl tbody"));
                 }
                 WAITINGDLG_hide();
             });

         });
   </script>

 </asp:Content>


